            
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>系统首页</title>
    <link rel="stylesheet" href="{$CSS}/bootstrap3.3.7.min.css">
    <link rel="stylesheet" type="text/css" href="/layui/css/layui.css">
    <style>
         td,th{
             text-align: center;vertical-align: middle !important;
             border-color:#C1DAD7 !important;
        }
        td input{
		    text-align: center;
            margin: 0 auto;
        }
        .info{
            background: #D5EDEF
        }
        .table-bordered{
            border-color:#D5EDEF
        }
    </style>
</head>

<body>
    <div style="padding:10px;border-bottom:1px solid #eee;font-size:15px;font-weight:700">导航菜单管理
</div>
    <div style="padding:20px">
       <form class="form-horizontal form-group" action="" method="post">
            <table class="table table-bordered table-hover">
              <thead>
                <tr class="info">
                  <th class="col-md-2">菜单名称</th>
                  <th class="col-md-2">是否显示</th>
				  <th class="col-md-2">链接地址</th>
				  <th class="col-md-2">操作</th>
                </tr>
              </thead>
              <tbody>
			  {loop $menuManage as $v}
                <tr>
                  <td>
					<input type="text" name="name@{$v->id}" value="{$v->name}"/>
                  </td>
                  <td>
					<input name="display@{$v->id}" type="radio" value="1" {if $v->display == 1} checked="checked" {/if}/>显示
					<input name="display@{$v->id}" type="radio" value="0" {if $v->display == 0} checked="checked" {/if}/>不显示
                  </td>
				  <td>
					<input type="text" name="url@{$v->id}" placeholder="需填写'http'或'https'" value="{$v->url}"/>
				  </td>
				  <td>
				  	<span class="btn btn-primary" onclick="delete_type({$v->id})">删除</span>
				  </td>
                </tr>
               {/loop}
              </tbody>
            </table>
            <div>
	            <a class="btn btn-primary" id="add_div">添加</a>

	            <button class="btn btn-primary" type="submit">提交</button>
            </div>
            
        </form>    
    </div>
    <form>
      <div class="" id="addDiv" style="display: none;">
        <div class="">
          <h2 class="" style="text-align: center; font-size: 20px; font-weight: bold; padding:20px 0;"> 预留菜单名称 </h2>
          <div class="layui-form-item">
              <label class="layui-form-label" style="width: 100px;">菜单名称:</label>
              <div class="layui-input-block">
                <input type="text" style="width: 90%;" name="name" id="name" class="layui-input" autocomplete="off" placeholder="请输入名称"> 
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label" style="width: 100px;">网址:</label>
              <div class="layui-input-block">
                <input type="text" style="width: 90%;" name="url" id="url" class="layui-input" autocomplete="off" placeholder="需填写'http'或'https"> 
              </div>
          </div>
          <div class="" style="display: flex; justify-content: flex-end;padding: 20px;margin-right: 40px;">
            <button id="" type="button" class="layui-btn layui-btn-primary layui-btn-sm" onclick="parent.layer.closeAll()" style=""> 取消</button>
            <button id="" type="button" class="layui-btn layui-btn-normal layui-btn-sm" onclick="add()"> 确定</button>
          </div>
        </div> 
      </div>
    </form>
</body>
<script src="/layui/layui.js"></script>
<script type="text/javascript">
	layui.use('layer', function(){
      var layer = layui.layer;
    }); 
	  //显示添加套餐弹框
	 $("#add_div").on('click',function(){
		layer.open({
	      title: [' ', 'font-weight:bold;'],
	      type: 1,
	      area: ['800px', '350px'],
	      shadeClose: true,
	      content: $('#addDiv')
	    })  
	 })
	     
	function add(){
	    var name = $("#name").val();
	    console.log(name);
	    if(!name){
	      layer.msg('请填写名称',!{icon: 5});
	      return false;
	    }
	    var url = $("#url").val();
	    if(!url){
	      layer.msg('请填写网址',!{icon: 5});
	      return false;
    	}
    	ajax('menuManageAdd-add.html',!{name:name,url:url},function(data){
	      console.log(data);
	      if(data == 'ok'){
	        layer.msg('操作成功',!{icon: 6});
	        setTimeout(function(){
	          goto(location.href);
	        },500);
	      }else{
	        layer.msg('操作失败',!{icon: 5});
	      }
	    });
  	}

  	function  delete_type(id){
	    if(confirm('确定删除此套餐吗？')){
	      ajax('menuManageAdd-del.html',{ id:id},function(data){
	        if(data == 'ok'){
	          tusi('操作成功');
	          setTimeout(function(){
	            goto(location.href);
	          },500);
	        }else if(data == 'no'){
	          tusi('操作失败');
	        }
	      });
	    } 
	}
</script>
</html>